package com.showgood.beans.handler;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.showgood.beans.proxy.GameUtil;
import com.showgood.beans.service.impl.ArmyService;
import com.showgood.meta.Army;
import com.showgood.socket.Session;
import com.showgood.util.math.Rect;
import com.showgood.vo.ArmyVO;
import com.showgood.vo.RectVO;
import com.showgood.vo.RemoteMessage;

@Component
public class QueryArmyHandler extends SingleVoArrayReplyHandler<RectVO, ArmyVO> {
	@Autowired
	private ArmyService armyService;
	@Override
	public int[] handleMessage() {
		return new int[] { RemoteMessage.REMOTE_QUERY_ARMY_ON_MAP };
	}
	@Override
	protected List<ArmyVO> handle(Session userSession, RectVO vo) {
		List<Army> armyList = armyService.findInRect(GameUtil.copyTo(vo, new Rect()));
		return GameUtil.conv(armyList, ArmyVO.class);
	}
}
